home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / lib / svdleg.pro < prev    next >
Text File  |  1997-07-08  |  603b  |  24 lines

  1. ; $Id: svdleg.pro,v 1.3 1997/01/15 03:11:50 ali Exp $
  2.  
  3. function svdleg,X,M
  4. ;
  5. ;       Legendre polynomial basis function 
  6. ;       generator for SVDFIT,/LEGENDRE
  7. ;
  8.         XX=X[0]                   ; ensure scalar XX
  9.     sz=reverse(size(XX))      ; use size to get the type
  10.         IF sz[n_elements(sz)-2] EQ 5 THEN $
  11.                 basis=DBLARR(M) else basis=FLTARR(M)
  12. ;
  13. ;       Calculate and return the basis functions
  14. ;
  15.     d=(basis[0]=1.0)
  16.         IF M ge 2 THEN f2=(basis[1]=XX)
  17.     FOR i=2,M-1 DO BEGIN
  18.         f1=d+1.0
  19.         f2=f2+2.0*XX
  20.         basis[i]=(f2*basis[i-1]-f1*basis[i-2])/d
  21.     ENDFOR
  22.     return,basis
  23. end
  24.